
import bpy

import 全局控制.Node.插座.bl_插座基类 as 插座基类
import Core.bl_UI配色 as UI配色

import engine.initLIB.load_dll as engineLib
import ctypes





class C_Socket_物体_Array1D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_物体_Array1D, self).__init__()

	def draw(self, context, layout, node, text):
		layout.label(text=text+'[Object]', icon='OBJECT_DATA')
		#self.display_shape = 'SQUARE'
	def draw_color(self, context, node):
		return (0.5, 0.5, 0.5, 1.0)
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
		'''bpy.data.objects.update()
		objs = []
		for obj in data:
			objs.append(bpy.data.objects[obj[1]])
		return objs;'''

	def f_setData(self, data):
		return engineLib.flexCAPI.f_bl_插座传入数据(
			ctypes.c_wchar_p(self.node.id_data.name), 
			ctypes.c_wchar_p(self.node.name), 
			ctypes.c_wchar_p(self.identifier), 
			ctypes.py_object(data),
			ctypes.c_bool(self.is_output)
		)

	def f_str(self):
		return list(f_getData())





class C_Socket_物体_Array2D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_物体_Array2D, self).__init__()

	def draw(self, context, layout, node, text):
		layout.label(text=text+'[[Object]]', icon='OBJECT_DATA')
		self.display_shape = 'SQUARE'
	def draw_color(self, context, node):
		return (0.5, 0.5, 0.5, 1.0)
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
		
	def f_setData(self, data):
		return engineLib.flexCAPI.f_bl_插座传入数据(
			ctypes.c_wchar_p(self.node.id_data.name), 
			ctypes.c_wchar_p(self.node.name), 
			ctypes.c_wchar_p(self.identifier), 
			ctypes.py_object(data),
			ctypes.c_bool(self.is_output)
		)

	def f_update(self):
		pass





class C_Socket_物体_Array3D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_物体_Array3D, self).__init__()
		self.display_shape = 'SQUARE'
	def draw(self, context, layout, node, text):
		layout.label(text=text+'[[[Object]]]', icon='OBJECT_DATA')
	def draw_color(self, context, node):
		return (0.5, 0.5, 0.5, 1.0)
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
		
	def f_setData(self, data):
		return engineLib.flexCAPI.f_bl_插座传入数据(
			ctypes.c_wchar_p(self.node.id_data.name), 
			ctypes.c_wchar_p(self.node.name), 
			ctypes.c_wchar_p(self.identifier), 
			ctypes.py_object(data),
			ctypes.c_bool(self.is_output)
		)

	def f_update(self):
		pass









class C_Socket_物体数据_Array1D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_物体数据_Array1D, self).__init__()

	def draw(self, context, layout, node, text):
		layout.label(text=text+'[Data]', icon='OBJECT_DATA')
		#self.display_shape = 'SQUARE'
	def draw_color(self, context, node):
		return (0.5, 0.5, 0.5, 1.0)
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
		
	def f_setData(self, data):
		return engineLib.flexCAPI.f_bl_插座传入数据(
			ctypes.c_wchar_p(self.node.id_data.name), 
			ctypes.c_wchar_p(self.node.name), 
			ctypes.c_wchar_p(self.identifier), 
			ctypes.py_object(data),
			ctypes.c_bool(self.is_output)
		)
		





class C_Socket_网格_Array1D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_网格_Array1D, self).__init__()
		self.display_shape = 'SQUARE'
	def draw(self, context, layout, node, text):
		layout.label(text=text+'[Mesh]', icon='IMGDISPLAY')
	def draw_color(self, context, node):
		return UI配色.g_Array1D_物体插座颜色
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
		
	def f_setData(self, data):
		pass





class C_Socket_网格_Array2D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_网格_Array2D, self).__init__()
		self.display_shape = 'SQUARE'
	def draw(self, context, layout, node, text):
		layout.label(text=text+'[[Mesh]]', icon='IMGDISPLAY')
	def draw_color(self, context, node):
		return UI配色.g_Array1D_物体插座颜色
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
		
	def f_setData(self, data):
		pass






class C_Socket_网格_Array3D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_网格_Array3D, self).__init__()

	def draw(self, context, layout, node, text):
		layout.label(text=text+'[[Mesh]]', icon='IMGDISPLAY')
		self.display_shape = 'SQUARE'
	def draw_color(self, context, node):
		return UI配色.g_Array1D_物体插座颜色
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
		
	def f_setData(self, data):
		pass













class C_Socket_物理材质_Array1D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_物理材质_Array1D, self).__init__()

	def draw(self, context, layout, node, text):
		layout.label(text=text+'[geom]', icon='MATERIAL')
	def draw_color(self, context, node):
		return UI配色.g_1D_物理材质插座颜色
	





class C_Socket_物理几何形状_Array1D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_物理几何形状_Array1D, self).__init__()
		self.display_shape = 'SQUARE'
		
	def draw(self, context, layout, node, text):
		layout.label(text=text+'[geom]', icon='MESH_ICOSPHERE')
	def draw_color(self, context, node):
		return UI配色.g_1D_物理几何形状插座颜色
	




class C_Socket_物理体_Array1D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_物理体_Array1D, self).__init__()
		#self.display_shape = 'SQUARE'
	def draw(self, context, layout, node, text):
		layout.label(text=text+'[physis]', icon='RIGID_BODY')
	def draw_color(self, context, node):
		return UI配色.g_1D_物理体插座颜色
	




















classes = (
	C_Socket_物体_Array1D,
	C_Socket_物体_Array2D,
	C_Socket_物体_Array3D,

	C_Socket_物体数据_Array1D,
	
	C_Socket_网格_Array1D,
	C_Socket_网格_Array2D,
	C_Socket_网格_Array3D,
	
	
	C_Socket_物理材质_Array1D,
	C_Socket_物理几何形状_Array1D,
	C_Socket_物理体_Array1D,
)

def register():
	for c in classes:
		bpy.utils.register_class(c)	

def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)
	




